# for create multi file inside a folder
import sys
import os

KBstring = "1234567890111213" * 64

if __name__ == "__main__":
    if len(sys.argv) != 4:
        print("Input error,format: python3 file_creator.py <file path> <file count> <file size><GB/MB/KB>")
        quit()

    num_file = int(sys.argv[2])
    file_size = 0
    root_path = sys.argv[1]+'/'
    #get file size from argv
    if("GB" in sys.argv[3]):
        file_size = int(sys.argv[3].split("GB")[0])*1024*1024
    elif("MB" in sys.argv[3]):
        file_size = int(sys.argv[3].split("MB")[0])*1024
    elif("KB" in sys.argv[3]):
        file_size = int(sys.argv[3].split("KB")[0])
    else:
        print("file size input error")
        quit()

    if os.path.exists(sys.argv[1]):
        print("create",num_file,"files of",file_size,"KB size in folder",root_path)
    else:
        print("path error:",sys.argv[1])
        quit()

    #start create file
    for i in range(num_file):
        f = open(root_path + "file" + str(i),"w")
        for j in range(file_size):
            f.write(KBstring)
        f.close()

    print("create file done")